{extend name="base/common"}

{block name="style"}
<link href="/static/summernote/summernote.css" rel="stylesheet">
<link href="/static/bootstrap-fileinput/css/fileinput.min.css" rel="stylesheet">
<link href="/static/js/jQuery-imgBox/imgbox.css" rel="stylesheet"/>
<style>

    .mail-box .mail-subject{
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 124px !important;
        min-width: 124px;
    }


    @media only screen and (max-width: 550px){
        .mail-date{
            display: none;
        }
    }


</style>
{/block}

{block name="page-header"}

{/block}

{block name="main"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="mail-box-header">
            <form method="get" action="index.html" class="pull-right mail-search">
                <div class="input-group">
                    <input type="text" class="form-control input-sm" name="search" placeholder="搜索活动名称" value="{$search}">
                    <div class="input-group-btn">
                        <button type="submit" class="btn btn-sm btn-primary">搜索</button>
                    </div>
                </div>
            </form>
            <h2>活动管理</h2>
            <div class="mail-tools tooltip-demo m-t-md">
                <!--<button class="btn btn-white btn-sm" data-toggle="tooltip" data-placement="top"><i class="fa fa-eye" style="margin-left: 3px"></i> </button>-->
                <a data-toggle="modal" class="btn btn-sm btn-primary" href="{:Url('Activity/add')}">添加活动</a>
            </div>
        </div>

        <div class="mail-box">
            <table class="table table-hover table-mail">
                <thead>
                <tr>

                    <th>活动名称</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>活动人数</th>
                    <th>集合地点</th>
                    <th>目的地点</th>
                    <th>报名人数</th>
                    <th> <select name="type" id="changeType" onchange="changeType()">
                        <option value="-1" {eq name="$checkType" value=""}selected{/eq}>状态</option>
                        <option value="0" {eq name="$checkType" value="0"}selected{/eq}>活动取消</option>
                        <option value="1" {eq name="$checkType" value="1"}selected{/eq}>预报名</option>
                        <option value="2" {eq name="$checkType" value="2"}selected{/eq}>开始报名</option>
                    </select></th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <td>{$vo.name|msubstr=0,8,'utf-8',true}</td>
                    <td>{empty name="$vo.start_time" }空
                        {else／}{$vo.start_time|date='Y-m-d',###}
                        {/empty}
                    </td>
                    <td>{empty name="$vo.end_time" }空
                        {else／}{$vo.end_time|date='Y-m-d',###}
                        {/empty}
                    </td>
                    <td>
                        {if condition="$vo.activity_number eq null"}
                        不限
                        {else/}
                        {$vo.activity_number}
                        {/if}
                    <td>{$vo.meeting_place|msubstr=0,10,'utf-8',true}</td>
                    <td>{$vo.destination_place|msubstr=0,10,'utf-8',true}</td>
                    <td>{$vo.comment}</td>
                    <td>{$vo.status_text}</td>
                    <td>
                        <a class="btn-sm btn-success"  href="{:Url('Activity/add?id='.$vo['id'])}">修改</a>
                        <a  class="btn-sm btn-primary" href="{:Url('Activity/recordinfo?id='.$vo['id'])}">查看报名情况</a>
                        <a class="btn-sm btn-success"    href="{:Url('outexcel','id='.$vo.id)}"  >导出</a>
                        {if condition="$vo.status == 1"}
                        <a href="{:Url('change','type=1&&id='.$vo.id)}" class="ajax-get confirm btn-sm btn-success">开始活动</a>
                        {else/} <a class="btn-default2">开始活动</a>
                        {/if}

                        {if condition="$vo.status ==2"}
                        <a class=" btn-sm btn-primary" data-toggle="modal" href="#modal-form" onclick="changestates('{$vo.id}')">取消活动</a>
                        {elseif condition="$vo.status ==1"}   <a class=" btn-sm btn-primary" data-toggle="modal" href="#modal-form" onclick="changestates('{$vo.id}')">取消活动</a>
                        {else/} <a class="btn-default2">取消活动</a>
                        {/if}



                       {if condition="$vo.status <2"}
                        <a   href="{:Url('Activity/del?id='.$vo['id'])}" class="confirm ajax-del btn-sm btn-danger">删除</a>
                        {else/} <a class="btn-default2">删除</a>
                        {/if}


                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="btn-group pull-right">{$list->render()}</div>
        </div>
    </div>
</div>
<div id="modal-form" class="modal fade" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <form class="form-horizontal" method="post" action="update">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h3 class="modal-title text-center">取消活动</h3>
                </div>
                <div class="modal-body">
                    <div class="clear">
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10"><input type="text" name="reply"   class="form-control" placeholder="请填写备注信息，不允许为空"></input></div>
                    </div>
                </div>
                <input name="id" type="hidden">
                <div class="modal-footer">
                    <div class="col-sm-12 text-center zt-flex zt-space-around">
                        <!--<input type="button"  class="form-control"    value="确认提交" onclick="changeStatus()" style="background-color: #1ab394;color: #fff;">-->
                        <a class="btn btn-primary " onclick="changeStatus()">确认</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{/block}

{block name="script"}
<script src="/admin/js/plugins/iCheck/icheck.min.js"></script>
<script src="/static/summernote/summernote.min.js"></script>
<script src="/static/summernote/lang/summernote-zh-CN.js"></script>
<script src="/static/bootstrap-fileinput/js/fileinput.min.js"></script>
<script src="/static/bootstrap-fileinput/themes/fa/fa.js"></script>
<script src="/static/bootstrap-fileinput/js/locales/zh.js"></script>
<script src="/static/js/jQuery-imgBox/jquery.imgbox.js"></script>
<script>
    $(document).ready(function(){
        $('.i-checks').iCheck({
            checkboxClass: 'icheckbox_square-green',
            radioClass: 'iradio_square-green',
        });
        $(".check-all").on("ifChanged",function(){
            $("tbody").find(".id").iCheck("toggle");
        });
    });

    $('.summernote').summernote({
        lang: 'zh-CN',
        height: 300,
        minHeight: 210,
        callbacks: {
            onImageUpload: function (files) { //the onImageUpload API
                img = sendFile(files[0]);
            }
        }
    });
    function changeType(){
        var types = $('#changeType').val();
        location.href = "{:Url('Activity/index')}?type="+types+"";

    }
    //增加模态框后的修改；
    function changestates(id) {
        $("input[name='id']").val(id);
    }

    /*修改服务状态值*/
    function changeStatus(){
        var data={};
            data={
                id : $("input[name='id']").val(),
                reply : $("input[name='reply']").val(),
                type  : 2
        }
        $.ajax({
            data:data,
            type:"POST",
            url:"{:Url('Activity/change')}",
            success:function (data){
                if(data.code==1){
                    updateAlert(data.msg+ ' 页面即将自动跳转~','success');
                    setTimeout(function(){
                        location.href=data.url;
                    },2000);
                }else{
                    updateAlert(data.msg,'info');
                }
            }
        })

    }
    highlight_subnav("{:Url('Activity/index')}");
</script>
{/block}